/*    */ package handling.channel;
/*    */ 
/*    */ import com.alibaba.druid.pool.DruidPooledConnection;
/*    */ import database.DatabaseConnection;
/*    */ import java.sql.PreparedStatement;
/*    */ import java.sql.ResultSet;
/*    */ import java.sql.SQLException;
/*    */ import java.util.LinkedList;
/*    */ import java.util.List;
/*    */ 
/*    */ 
/*    */ public class MapleGuildRanking
/*    */ {
/* 14 */   private static final MapleGuildRanking instance = new MapleGuildRanking();
/* 15 */   private final List<GuildRankingInfo> ranks = new LinkedList<>();
/*    */   
/*    */   public static MapleGuildRanking getInstance() {
/* 18 */     return instance;
/*    */   }
/*    */   
/*    */   public void load() {
/* 22 */     if (this.ranks.isEmpty()) {
/* 23 */       reload();
/*    */     }
/*    */   }
/*    */   
/*    */   public List<GuildRankingInfo> getRank() {
/* 28 */     return this.ranks;
/*    */   }
/*    */   
/*    */   private void reload() {
/* 32 */     this.ranks.clear();
/* 33 */     try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
/* 34 */       PreparedStatement ps = con.prepareStatement("SELECT * FROM guilds ORDER BY `GP` DESC LIMIT 50");
/* 35 */       ResultSet rs = ps.executeQuery();
/*    */       
/* 37 */       while (rs.next()) {
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */         
/* 44 */         GuildRankingInfo rank = new GuildRankingInfo(rs.getString("name"), rs.getInt("GP"), rs.getInt("logo"), rs.getInt("logoColor"), rs.getInt("logoBG"), rs.getInt("logoBGColor"));
/*    */         
/* 46 */         this.ranks.add(rank);
/*    */       } 
/* 48 */       ps.close();
/* 49 */       rs.close();
/* 50 */     } catch (SQLException e) {
/* 51 */       System.err.println("Error handling guildRanking" + e);
/*    */     } 
/*    */   }
/*    */   
/*    */   public static class GuildRankingInfo
/*    */   {
/*    */     private final String name;
/*    */     private final int gp;
/*    */     private final int logo;
/*    */     private final int logocolor;
/*    */     private final int logobg;
/*    */     private final int logobgcolor;
/*    */     
/*    */     public GuildRankingInfo(String name, int gp, int logo, int logocolor, int logobg, int logobgcolor) {
/* 65 */       this.name = name;
/* 66 */       this.gp = gp;
/* 67 */       this.logo = logo;
/* 68 */       this.logocolor = logocolor;
/* 69 */       this.logobg = logobg;
/* 70 */       this.logobgcolor = logobgcolor;
/*    */     }
/*    */     
/*    */     public String getName() {
/* 74 */       return this.name;
/*    */     }
/*    */     
/*    */     public int getGP() {
/* 78 */       return this.gp;
/*    */     }
/*    */     
/*    */     public int getLogo() {
/* 82 */       return this.logo;
/*    */     }
/*    */     
/*    */     public int getLogoColor() {
/* 86 */       return this.logocolor;
/*    */     }
/*    */     
/*    */     public int getLogoBg() {
/* 90 */       return this.logobg;
/*    */     }
/*    */     
/*    */     public int getLogoBgColor() {
/* 94 */       return this.logobgcolor;
/*    */     }
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\handling\channel\MapleGuildRanking.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */